package t20211225;

import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Random;

/**
 * @Author: DengJia
 * @Date: 2021/12/25 19:46
 * @Description:
 */

public class PriorityQueueDemo {
    public static void main(String[] args) {
        Random random = new Random(47);
        PriorityQueue<Integer> queueI = new PriorityQueue<>();
        PriorityQueue<Double> queueD = new PriorityQueue<>();

        for (int i = 0; i < 20; i++) {
            queueI.offer(random.nextInt(20));
        }
        for (int i = 0; i < 20; i++) {
            queueD.offer(random.nextDouble());
        }

        while (queueI.peek() != null) {
            System.out.print(queueI.remove() + " ");
        }
        System.out.println();
        while (queueD.peek() != null) {
            System.out.print(queueD.remove() + " ");
        }

        PriorityQueue<ToolClass> queue = new PriorityQueue<>();

        queue.offer(new ToolClass());
        // 会报错，因为类没有比较器。
        // queue.offer(new ToolClass());
        // queue.offer(new ToolClass());
        new HashMap<>();

    }
}
